package com.flyco.modules.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.flyco.modules.pms.entity.PmsSpuProduct;
import com.flyco.modules.pms.mapper.PmsSpuMapper;
import com.flyco.modules.pms.mapper.PmsSpuProductMapper;
import com.flyco.modules.pms.service.IPmsSpuProductService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Collection;

/**
 * @Description: SPU管理
 * @Author: flyco
 * @Date:   2020-03-09
 * @Version: V1.0
 */
@Service
public class PmsSpuProductServiceImpl extends ServiceImpl<PmsSpuProductMapper, PmsSpuProduct> implements IPmsSpuProductService {

    @Override
    public void delMain(String id) {
        LambdaQueryWrapper<PmsSpuProduct> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PmsSpuProduct::getSpu,id);
        PmsSpuProduct spuProduct = new PmsSpuProduct();
        spuProduct.setSpu(null);
        this.update(spuProduct,queryWrapper);
    }

    @Override
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for(Serializable id:idList) {
            delMain(String.valueOf(id));
        }
    }
}
